import {
	logger
} from "runjs/lib/common"
import Vue from "vue"
import Vuex from "vuex"
Vue.use(Vuex)
const state = {
	timestamp: '',
	message: '',
	voiceUrl: '',
	orderNo: '',
	notifyTime: '',
	technicianName: '',
	technicianTel: '',
	timestampOrder:'',
	type: '' //0:后台订单提醒 1:后台订单异常 2:技师求救sos 3:技师待接单 4:技师服务待结束
}

const mutations = {
	//保存数据
	getWsMsg(state, data) {
		state.message = data.message
		state.voiceUrl = data.voiceUrl
		state.timestamp = data.timestamp
		state.timestampOrder = data.timestampOrder
		state.notifyTime = data.notifyTime
		state.technicianName = data.technicianName
		state.technicianTel = data.technicianTel
		state.type = data.type
		state.orderNo = data.orderNo
		console.log('store保存数据', state.voiceUrl)
	},
	// 重置
	resetMsg(state) {
		state.timestamp = ''
		state.timestampOrder=''
		state.message = ''
		state.voiceUrl = ''
		state.orderNo = ''
		state.notifyTime = ''
		state.technicianName = ''
		state.technicianTel = ''
		state.type = '' //0:后台订单提醒 1:后台订单异常 2:技师求救sos 3:技师待接单 4:技师服务待结束
	},
	//清除数据
	SET_CLEAR_DATA(state, data) {
		state = data
	}
}
const actions = {
	//保存数据
	changeSetting({
		commit
	}, data) {
		console.log('changeSetting', data)
		commit('getWsMsg', data);
	},
	//清除数据
	clearVuex({
		commit
	}) {
		commit("SET_CLEAR_DATA", null);
	},

}
const getters = {
	voiceUrl(state) {
		console.log('changgettersvoiceUrl', state.voiceUrl)
		return state.voiceUrl
	},
	message(state) {
		console.log('changgettersvoiceUrl', state.message)
		return state.message
	},
	orderNo(state) {
		console.log('changgettersvoiceUrl', state.orderNo)
		return state.orderNo
	},
	notifyTime(state) {
		console.log('changgettersvoiceUrl', state.notifyTime)
		return state.notifyTime
	},
	type(state) {
		console.log('changgettersvoiceUrl', state.type)
		return state.type
	},
}
export default {
	//解决模块名冲突
	namespaced: true,
	state,
	mutations,
	getters,
	actions

}